<?php
namespace Common\Model;
use Common\Model\BaseModel;
/**
* 学校标签关联表model
*/
class ArticleUserModel extends BaseModel{

    /**
     * 添加数据
     * @param string $aid 学校id
     * @param array $tids 标签id
     */
    public function addData($aid,$uid,$type){

            $data=array(
                'aid'=>$aid,
                'uid'=>$uid,
                'type'=>$type,
                'create_time'=>time()
                );
            $this->add($data);

        return true;
    }



    // 传递aid和true时获取tid数组；传递aid和tname获得键名为aid键值为tname的数组
    public function getDataByAid($aid){
        $data=$this->where(array('aid'=>$aid))->limit(3)->order('id desc')->select();
        foreach($data as $k=>$v){
            $data[$k]['create_time1']=date('Y-m-d H:i:s',$v['create_time']);
            $data[$k]['username']=get_username($v['uid']);
            if($v['type']==0){
                $data[$k]['type1']='添加';
            }else{
                $data[$k]['type1']='编辑';
            }

        }
        return $data;
    }


}




